<?php
/**
 *  Menu Callbacks
 */
function listing_address_settings_form() {
  // settings for default and content type
  $form['listing_address_ctypes'] = array(
    '#type'          => 'select',
	'#options'		 => variable_get('listing_content_types', array()),
    '#title'         => t('Single Country'),
    '#default_value' => variable_get('listing_address_ctypes', array()),
    '#description'   => t("Listing content types to use for address search.  Note that these content types have to be selected for listings."),
	'#multiple'		 => TRUE
  );
  $form['listing_address_single_country'] = array(
    '#type'          => 'checkbox',
    '#title'         => t('Single Country'),
    '#default_value' => variable_get('listing_address_single_country', 0),
    '#description'   => t("If you wish to use Address Search for a single country, tick this box and then select the country."),
  );
  $form['listing_address_country_select'] = array(
    '#type'          => 'select',
    '#title'         => t('Select Country'),
	'#options' 		 => listing_address_country_get(),
    '#default_value' => variable_get('listing_address_country_select', 'nz'),
    '#description'   => t("If you are using Address Search for a single country, select the country here.  This selection only applies if the Single Country box is ticked."),
  );
  //$form['#validate'][] = 'listing_address_settings_validate';
  return system_settings_form($form);
}
function listing_address_country_settings_report() {
  $result = db_query("SELECT * FROM {node} n INNER JOIN {content_type_job} j ON n.nid=j.nid WHERE j.field_job_address_country ='' OR j.field_job_address_province='' AND n.type='job'");
  $links = array();
  while ($row = db_fetch_object($result)) {
    $links[$row->nid]['title'] = $row->title;
	$links[$row->nid]['href'] = 'node/'.$row->nid;	
  }
  if (!empty($links)) {
	return '<div>'.t('The following nodes do not have country/province data').'</div>'.theme('links', $links);
  }
  else return "All job nodes have relevant country/province data";
}
